package org.gl.training.planner.service;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;

import org.gl.training.planner.dao.UserDao;
import org.gl.training.planner.model.User;

@ManagedBean(name = "infoBean")
@RequestScoped
public class InfoBean {

	@ManagedProperty(value = "#{param.id}")
	private Integer id;

	private User user;

	@EJB
	private UserDao userDao;

	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public User getUser() {
		if (user == null) {
			user = userDao.find(id);
		}
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}
